<!-- right content-->
<?php
$allCategory = $this->allCategory;
$catID = $this->catID;
$currentCat = @$allCategory[$catID];
$cat = new Category();

/*
// update curentCat if it's sub-cat
if ($currentCat['parent'] != 1) {
    @$parentID = $currentCat['parent'];
    
    @$currentCat = $allCategory[$parentID];
    @$allChild = $currentCat['children'];
}
*/
?>
<div style="padding:5px; border:1px solid #000;">
<?php
        @$allParent = $allCategory[$catID]['all_parent'];
        $arrParent = explode(',', $allParent);
        $first = true;
        $cat_id = 0;
        foreach($arrParent as $parent_id):
            @$parent = $allCategory[$parent_id];
            if ($parent['left'] != 1) {
        ?>
            <a href="<?php echo $cat->url($parent)?>"><?php echo $parent['admin_title']?></a> &raquo;
        <?php
            }
        endforeach;

?>
    <?php echo @$currentCat['admin_title']?>
</div>
<?php
// update curentCat if it's sub-cat
if ($currentCat['parent'] != 1) {
    @$parentID = $currentCat['parent'];
    
    @$currentCat = $allCategory[$parentID];
    @$allChild = $currentCat['children'];
}
?>
<!-- space-->
<div style="padding:5px; "></div>
<!-- end space-->
<table width="100%">
    <tr>
    <?php
    if(@$currentCat['main_image']) {
        $image = @$currentCat['main_image'];
        //echo stripos($image, 'http');
        
        if (stripos($image, 'http') === false) {
            $image = BASE_PATH . $image;
        } else {
            //echo $image = BASE_PATH . $image;
            // do nothing
        }
    ?>
        <td>
            <center>
            <?php
            if(@$currentCat['photo_link']) {
            ?>
            <a href="<?php echo $currentCat['photo_link']?>">
                <img src='<?php echo htmlspecialchars($image);?>'>
            </a>
            <?php
            } else {
            ?>
                <img src='<?php echo htmlspecialchars($image);?>'>
            <?php
            }
            ?>
            </center>
        </td>
    <?php
    }
    ?>
    <?php
    if(@$currentCat['embed_youtube']) {
        $video = $currentCat['embed_youtube'];
    ?>
    <?php
    } else {
        $config = $config = Vnf::getConfigs('conf');
        $video = $config->defaultCatVideo;
    }
    ?>
        <td width="260">
            <a href="<?php echo $video;?>" class="media"></a>
        </td>
    </tr>
</table>
<div style="padding: 10px 0px;">
    <?php echo @$currentCat['description']?>
</div>


<!-- List product-->
<div id="listproduct">
        <?php
        //print_r($currentCat);
        ?>
            <?php
            
            @$allChild = $currentCat['children'];
            
            
            $objCat = new Category();
            if (count($allChild) > 0) {
            ?>
    <div style="float:left;">
        <form method="post" action="">
            <span style="color:#FFF;">Sort By Sub-Category</span>
            <select onchange="document.location.href=this.options[this.selectedIndex].value;">
            <option value="<?php echo $objCat->url($currentCat)?>">--select one--</option>
            <?php
                foreach($allChild as $childID):
                    $cat = $allCategory[$childID];
            ?>
                <option value="<?php echo $objCat->url($cat)?>" <?php if($this->catID == $cat['category_id']) echo "selected";?>><?php echo $cat['admin_title']?></option>
            <?php
                endforeach;
            ?>
            </select>
        </form>
    </div>
    <div style="float:right;">
        <a href="<?php echo BASE_URL?>/index/shop/list/?cid=<?php echo $currentCat['category_id']?>&all=1">See all <?php echo @$currentCat['admin_title']?> products</a>
    </div>
            <?php
            } else {
            ?>
                <span style="color:#FFF;">List products</span>
            <?php
            }
            ?>
    <div style="clear:both;"></div>
</div>
<table width="100%" cellspacing="0" cellpadding="0" id="products">
    <tr>
<?php
    $allItems = $this->allItems;
    $currentPage = $this->currentPage;
?>
<?php
if (isset($allItems[0])) {
    $i = 0;
    $itemPerRow = 4;
    $widthPercent = 100/$itemPerRow;
    foreach($allItems as $item):
        if ( ($i++ % $itemPerRow == 0) && ($i != 1)) {
    ?>
        </tr>
        <tr>
    <?php
        }
    ?>
        <td width="<?php echo $widthPercent?>%">
            <div>
                <a title="<?php echo htmlspecialchars($item->Product); ?>" class="thumbnail" href="<?php echo BASE_URL ?>/index/shop/detail?pid=<?php echo $item->category_id; ?>&id=<?php echo $item->ProductNo; ?>"><?php echo $item->Product; ?></a>
            </div>
            <?php
            $Thumbnail = $item->Thumbnail;
                if ($Thumbnail) {
                    if (stripos($Thumbnail, 'http') === false) {
                $Thumbnail = BASE_PATH . $Thumbnail;
            } else {
                //echo $image = BASE_PATH . $image;
                // do nothing
            }
            ?>
            <div style="padding: 10px 0px">
                <a title="<?php echo htmlspecialchars($item->Product); ?>" class="thumbnail" href="<?php echo BASE_URL ?>/index/shop/detail?pid=<?php echo $item->category_id; ?>&id=<?php echo $item->ProductNo; ?>"><img style="max-height: 80px;" alt="<?php echo htmlspecialchars($item->Product); ?>" src="<?php echo htmlspecialchars($Thumbnail)?>"></a>
            </div>
            <?php
            }
            
            $defaultNamespace = new Zend_Session_Namespace('Default');
            if (($item->AuthReq != "Yes") || ($defaultNamespace->access== true)) {
                  if($item->ShowPriceYN  == "Yes")
            {
                    $lineThrough = '';
                    $salePrice = '';
                    if ($item->PriceRetail && $item->PriceRetail > 0) {
                        $lineThrough = ' style="text-decoration: line-through;"';
                        $salePrice = '<strong style="color:red">\$' . $item->PriceRetail . '</strong>';
                    }
                                
            ?>
            <div>
                    Price - <strong <?php echo $lineThrough;?>>$<?php echo $item->Price?></strong>&nbsp; 
                    <?php echo $salePrice;?>
            </div>
            <?php
            }
            } // check login
            ?>
            <div style="padding-bottom:20px">
                <a title="<?php echo htmlspecialchars($item->Product); ?>" class="thumbnail" href="<?php echo BASE_URL ?>/index/shop/detail?pid=<?php echo $item->category_id; ?>&id=<?php echo $item->ProductNo; ?>"><img alt="More Info" src="<?php echo JS_PATH?>/skincarebyalana/images/moreInfo.png"/></a>
                <?php 
                if ($item->Price) { // just show buy button if price enter in admin 
                    if (($item->AuthReq != "Yes") || ($defaultNamespace->access== true)) { 
                        if($item->AddToCartYN == 'Yes' )
                        {
                    ?>
                            <img alt="More Info" src="<?php echo JS_PATH?>/skincarebyalana/images/buyit.gif" rel="<?php echo $item->ProductNo; ?>" class="buynow">
                    <?php
                        }
                    } // if AuthReq
                }
                ?>
            </div>
        </td>
    <?php
    endforeach;
} // if items
?>
    </tr>
</table>
<?php echo $this->paging?>
<!-- End List product-->
                        
                            
<script type="text/javascript" src="<?=JS_PATH?>/jquery/media/jquery.media.js"></script> 
<!--script type="text/javascript" src="<?=JS_PATH?>/jquery/jquery.metadata.js"></script--> 
<!--script type="text/javascript" src="http://github.com/malsup/media/raw/master/jquery.media.js?v0.92"></script-->
<script type="text/javascript">
    $(function() {
        $.fn.media.defaults.flvPlayer = '<?=JS_PATH?>/jquery/media/mediaplayer.swf';
        $.fn.media.defaults.mp3Player = '<?=JS_PATH?>/jquery/media/mediaplayer.swf';
        $('a.media').media( { width: 250, height: 187, type:'swf' } );
    });
</script>
